import wordcloud
from imageio import imread

f=open("《西游记》.txt",encoding='utf-8')

txt=f.read()
f.close()
bg_pic=imread('pic(2).jpg')
wcloud=wordcloud.WordCloud(
    font_path='C:\Windows\Fonts\msyh.ttc',
    background_color="white",
    width=1000,height=860,
    max_words=500,margin=1,
    mask=bg_pic
).generate(txt)
wcloud.to_file("02.png")
print("End....")